
package com.imcrl.core.state
{
	import com.imcrl.core.imcrl_internal;
	import com.imcrl.event.StateEvent;
	
	import starling.display.Sprite;
	
	public class Scene extends Sprite implements IState
	{
		protected var _initialized:Boolean=false;
		protected var _name:String;
		
		protected var _nextScene:String;
		protected var _machine:StateMachine;
		
		public function get nextScene():String{
			return _nextScene;
		}
		
		public function Scene(name:String)
		{
			this.name=name;
		}
		
		public function set machine(value:StateMachine):void{
			_machine=value;
		}
		
		public function get initialized():Boolean{
			return _initialized
		}
		
		public function initialize():void
		{
			_initialized=true;
		}
		
		public function start():void
		{
			if(this.hasEventListener(StateEvent.START)){
				this.dispatchEvent(new StateEvent(StateEvent.START));
			}
		}
		
		public function end():void
		{
			if(this.hasEventListener(StateEvent.END)){
				this.dispatchEvent(new StateEvent(StateEvent.END));
			}
		}
	}
}